package com.show.business.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.show.business.device.bean.DeploymentLocation;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author shop
 */
public class TreeSelect implements Serializable
{
    private static final Long serialVersionUID = 1L;

    /** 节点ID */
    private String id;

    /** 节点名称 */
    private String label;

    private String locationType;
    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(DeploymentLocation deploymentLocation)
    {
        this.id = deploymentLocation.getId();
        this.label = deploymentLocation.getName();
        this.locationType = deploymentLocation.getLocationType();
        if(deploymentLocation.getChildren()!=null){
            this.children = deploymentLocation.getChildren().stream().filter(obj -> obj != null).map(TreeSelect::new).collect(Collectors.toList());
        }else{
            this.children = null;
        }
    }

    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public String getLocationType() {
        return locationType;
    }

    public void setLocationType(String locationType) {
        this.locationType = locationType;
    }

    public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }
}
